import Router from 'koa-router';
import realtimeRouter from './realtime/index.js';
import datasourceRouter from './datasource/index.js';
import sqlqueryRouter from './sqlQuery/index.js';
import checkUserRouter from './checkUser/index.js';

// 注册所有路由
export default app => {
  // API 前缀
  const router = new Router({
    prefix: '/webDataApi'
  });

  // 注册子路由
  router.use(realtimeRouter.routes(), realtimeRouter.allowedMethods());
  router.use(datasourceRouter.routes(), datasourceRouter.allowedMethods());
  router.use(sqlqueryRouter.routes(), sqlqueryRouter.allowedMethods());
  router.use(checkUserRouter.routes(), checkUserRouter.allowedMethods());

  // 将路由挂载到应用
  app.use(router.routes()).use(router.allowedMethods());
}; 